#ifndef __HELLOWORLD_SCENE_H__
#define __HELLOWORLD_SCENE_H__

#include <vector>

#include "cocos2d.h"

#include "SimpleAudioEngine.h"
#include "Common/Exd/EXData.h"

class JumpBlock;
class Jumper;
class StageScene;
class LoopBackGround;
class AnimationMng;

class MainGameLayer : public cocos2d::CCLayer
{
public:
    // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
    bool init(StageScene* scn, int stageID);  

    // a selector callback
    void menuCloseCallback(CCObject* pSender);

    // implement the "static node()" method manually

	static MainGameLayer* create(StageScene* scn,int stageID) 
	{ 
		MainGameLayer *pRet = new MainGameLayer(); 
		if (pRet && pRet->init(scn,stageID)) 
		{ 
			pRet->autorelease(); 
			return pRet; 
		} 
		else 
		{ 
			delete pRet; 
			pRet = NULL; 
			return NULL; 
		} 
	}
    //CREATE_FUNC(MainGameLayer);


    void	Tick(float dt);

	void	AddNewJumpBlock();


	void	AddNewJumper();

	//call_back
	virtual void ccTouchesBegan(cocos2d::CCSet *touches, cocos2d::CCEvent* _event);
	//virtual void ccTouchesMoved(cocos2d::CCSet *touches,cocos2d::CCEvent *_event);

	virtual void ccTouchesEnded(cocos2d::CCSet *touches,cocos2d::CCEvent *_event);


	void	GameStartCallBack();
	void	JumpOverCallBack();
	void	JumpAnimOverCallBack();
	void	PullBackCallBack();


	void	JumpOn();

	void	Punish();


	void	Pause();
	void	Resume();

private:
	bool	IsBlockForbid(JumpBlock* block);

	void	AddPoint();

public:
	StageScene*					topScn;

	std::vector<JumpBlock*>		blocks;
	int							blockIdx;

	Jumper*						jumper;

	cocos2d::CCTexture2D*		m_pSpriteTexture;    
	cocos2d::CCTexture2D*		m_pJumperTexture;    

	cocos2d::CCPoint			touchPoint;

	bool						isJump;
	
	dn::EXD_Line_Stage*			stageData;

	int							forbidColor;
	int							forbidShap;
	int							forbidNum;

	std::vector<int>			allAllowColor;
	std::vector<int>			allAllowShap;

	std::vector<int>			allNumber;
	std::vector<int>			allAllowNumber;

	bool						overJump;
	int							point;
	int							combo;

	bool						isScaling;
	bool						isGameStarted;


	cocos2d::CCParticleSystem*	comboParticle;

	int							posCorrectedValue;
	

	int							scalingSpeed;

	AnimationMng*				animationMng;

	//-------------------------------------------------

	cocos2d::CCTexture2D*		m_pBG3Texture;    
	cocos2d::CCTexture2D*		m_pBG2ATexture;    
	cocos2d::CCTexture2D*		m_pBG2BTexture;    
	cocos2d::CCTexture2D*		m_pBG1Texture;    
	cocos2d::CCTexture2D*		m_pBG0Texture;    
	cocos2d::CCTexture2D*		m_pBGMoonTexture;    

	LoopBackGround*				bg3;
	LoopBackGround*				bg2a;
	LoopBackGround*				bg2b;
	LoopBackGround*				bg1;
	LoopBackGround*				bg0;
	LoopBackGround*				bgmoon;

	//--------------------------------------------------
};

#endif  // __HELLOWORLD_SCENE_H__